# 导包
import unittest
import app
from api.order import OrderAPI


# 创建测试类
class TestOrderAPI(unittest.TestCase):

    # 初始化
    order_id = None

    # 前置处理
    def setUp(self) -> None:
        self.order_api = OrderAPI()

    # 后置处理
    def tearDown(self) -> None:
        pass

    # 获取订单列表信息
    def test01_get_order_list(self):
        response = self.order_api.get_order_list()
        print(response.json())
        # 断言
        self.assertEqual(200, response.status_code)
        self.assertEqual(1, response.json().get("current_page"))

    # 创建订单
    def test02_cate_order(self):
        response = self.order_api.cate_order(app.insert_data)
        print(response.json())
        # 断言
        self.assertEqual(200, response.status_code)
        self.assertEqual(True, response.json().get("pass"))
        # 提取返回数据
        TestOrderAPI.order_id = response.json().get("order_id")
        print(TestOrderAPI.order_id)

    # 获取订单详情信息
    def test03_get_order(self):
        response = self.order_api.get_order(TestOrderAPI.order_id)
        print(response.json())
        # 断言
        self.assertEqual(200, response.status_code)
        self.assertEqual(1, response.json().get("status"))







































































